/**
 * Copyright (C) 2011 Andrew C. Love (DNC) <dnc.app.sup@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dnc.cloak.framework.messaging;

import java.io.Serializable;
import java.util.Map;
import java.util.TreeMap;

public class MessageImpl implements Message, Serializable{
    private String id;
    private String result;
    private String errorMessage;
    private String response;
    private String request;
    private String message;
    private String messageType;
    private String protocolID;
    private Map<String, Object> m_map = new TreeMap<String, Object> ();
    
    public String getErrorMessage() {
        return this.errorMessage;
    }

    public String getID() {
        return this.id;
    }
    
    public String getRequest() {
        return this.request;
    }

    public String getResponse() {
        return this.response;
    }

    public String getResult() {
        return this.result;
    }

    public String getMessageType() {
        return messageType;
    }

    public String getProtocolID() {        
        return protocolID;
    }

    public String getMessage() {
        return message;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public void setID(String id) {
        this.id = id;   
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }

    public void setProtocolID(String protocolID) {
        this.protocolID = protocolID;        
    }

    public void setRequest(String request) {
        this.request = request;        
    }

    public void setResponse(String response) {
        this.response = response;        
    }    

    public Object getProperty(String key){        
        return m_map.get(key);
    }

    public void setProperty(String key, Object value){        
        m_map.put(key,value);
    }
    
    public void setResult(String result) {
        this.result = result;        
    }

    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("Message [m_map=");
        builder.append(m_map);
        builder.append(", getErrorMessage()=");
        builder.append(getErrorMessage());
        builder.append(", getID()=");
        builder.append(getID());
        builder.append(", getMessage()=");
        builder.append(getMessage());
        builder.append(", getMessageType()=");
        builder.append(getMessageType());
        builder.append(", getProtocolID()=");
        builder.append(getProtocolID());
        builder.append(", getRequest()=");
        builder.append(getRequest());
        builder.append(", getResponse()=");
        builder.append(getResponse());
        builder.append(", getResult()=");
        builder.append(getResult());
        builder.append("]");
        return builder.toString();
    }
}
